﻿Imports System.Web.UI
Imports DotNetNuke

Namespace DotNetNuke.Modules.ActiveForums
    Partial Public Class ActiveForums
        Inherits ForumBase
        Implements DotNetNuke.Entities.Modules.IActionable


#Region "DNN Actions"
        Public ReadOnly Property ModuleActions() As Entities.Modules.Actions.ModuleActionCollection Implements Entities.Modules.IActionable.ModuleActions
            Get
                Dim Actions As New Entities.Modules.Actions.ModuleActionCollection
                Actions.Add(GetNextActionID, Utilities.GetSharedResource("[RESX:ControlPanel]"), Entities.Modules.Actions.ModuleActionType.AddContent, "", "", EditUrl(), False, Security.SecurityAccessLevel.Edit, True, False)
                'Actions.Add(GetNextActionID, Utilities.GetSharedResource("ForumEditor"), Entities.Modules.Actions.ModuleActionType.AddContent, "", "", EditUrl("ForumEditor"), False, Security.SecurityAccessLevel.Edit, True, False)
                Return Actions
            End Get
        End Property
#End Region

#Region "Event Handlers"

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim defaultView As String = "classic"
            If Not Settings("amafDefaultView") Is Nothing Then
                If Not String.IsNullOrEmpty(Settings("amafDefaultView").ToString) Then
                    defaultView = Settings("amafDefaultView").ToString
                End If
            End If
            If Not Page.IsPostBack Then
                plhAF.Controls.Clear()
            End If

            If defaultView.ToLowerInvariant = "advanced" Then
                Dim ctl2 As Controls.ControlsBase = Nothing
                ctl2 = CType(LoadControl("~/desktopmodules/activeforums/advanced.ascx"), Controls.ControlsBase)
                ctl2.ModuleConfiguration = Me.ModuleConfiguration
                plhAF.Controls.Add(ctl2)
            ElseIf PortalSettings.UserTabId = PortalSettings.ActiveTab.ParentId Then
                Dim userId As Integer = -1
                If Request.QueryString("UserId") Is Nothing Then
                    userId = UserInfo.UserID
                Else
                    userId = Convert.ToInt32(Request.QueryString("UserId"))
                End If
                If userId = UserInfo.UserID Or UserInfo.IsInRole(PortalSettings.AdministratorRoleName) Then
                    Dim ctl2 As SettingsBase = Nothing
                    ctl2 = CType(LoadControl("~/desktopmodules/activeforums/controls/profile_mypreferences.ascx"), SettingsBase)
                    ctl2.ModuleConfiguration = Me.ModuleConfiguration
                    ctl2.LocalResourceFile = "~/desktopmodules/activeforums/app_localresources/sharedresources.resx"
                    plhAF.Controls.Add(ctl2)
                End If
                
            Else
                Dim ctl As ForumBase = Nothing
                ctl = CType(LoadControl("~/desktopmodules/activeforums/classic.ascx"), ForumBase)
                ctl.ModuleConfiguration = Me.ModuleConfiguration
                plhAF.Controls.Add(ctl)
            End If


        End Sub


#End Region




    End Class
End Namespace